package com.sky.controller;

import com.sky.dto.ArticlePageQueryDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.impl.ArticleServiceImpl;
import com.sky.vo.ArticleSortVO;
import com.sky.vo.ArticleVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/article")
@Slf4j
@Api(tags = "文章相关接口")
public class ArticleController {
    @Autowired
    private ArticleServiceImpl articleService;

    /**
     * 文章查询全部
     * @return
     */
    @ApiOperation("文章分页查询")
    @GetMapping("/list")
    @CrossOrigin("http://localhost:5173")
    public Result<PageResult> page(ArticlePageQueryDTO articlePageQueryDTO){
        log.info("文章分页查询:{}",articlePageQueryDTO);
        PageResult pageResult = articleService.pageQuery(articlePageQueryDTO);
        return Result.success(pageResult);
    }
}
